﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DTO;
using BUS;
namespace GUI
{
    public partial class TraCuuChuyenBay_HK : Form
    {
        public TraCuuChuyenBay_HK()
        {
            InitializeComponent();
        }
        public void HienThi()
        {
            this.dataGridView1.AutoGenerateColumns = false;
            String noiDi = comboBox1.SelectedValue.ToString();
            String noiDen = comboBox1.SelectedValue.ToString();
            DateTime ngayDi =dateTimePicker1.Value;
            this.dataGridView1.DataSource = CT_ChuyenBay_BUS.traCuuChuyenBay(noiDi, noiDen, ngayDi);
            List<CT_ChuyenBay_DTO> ds = CT_ChuyenBay_BUS.layDanhSachChuyenBay();
           // dataGridView1.Rows.Clear();
         //   for (int i = 0; i < ds.Count; i++)
         //   {
          //      dataGridView1.Rows.Add(ds[i].maCB, ds[i].soGheHang1, ds[i].soGheHang2, ds[i].giaHang1, ds[i].giaHang2, ds[i].gioDi, ds[i].gioDen);

          //  }
        }
        private void TraCuuChuyenBay_Load(object sender, EventArgs e)
        {
            this.comboBox1.ValueMember = "Tinh";
            this.comboBox1.DisplayMember = "Tinh";
            this.comboBox4.ValueMember = "Tinh";
            this.comboBox4.DisplayMember = "Tinh"; 
            this.comboBox1.DataSource = ChuyenBay_BUS.layDanhSachChuyenBay();

            this.HienThi();
        }
        private void button_tim_Click(object sender, EventArgs e)
        {
            //Lấy thông tin 
            if (comboBox1.Text.Trim() == "")
                MessageBox.Show("Xin vui lòng chọn một nơi đi!");
            if(comboBox4.Text.Trim() =="")
                MessageBox.Show("Xin vui lòng chọn một nơi đến!");
            
            String noiDi = comboBox1.Text.ToString();
            String noiDen = comboBox4.Text.ToString();
            DateTime ngayDi = DateTime.Parse(dateTimePicker1.Value.ToShortDateString());
            List<CT_ChuyenBay_DTO> ds = CT_ChuyenBay_BUS.traCuuChuyenBay(noiDi, noiDen, ngayDi);
            if (ds != null)
                dataGridView1.Rows.Clear();
            for (int i = 0; i < ds.Count ; i++)
			{
			  dataGridView1.Rows.Add(ds[i].maCB, ds[i].soGheHang1, ds[i].soGheHang2, ds[i].giaHang1, ds[i].giaHang2, ds[i].gioDi, ds[i].gioDen);
        
			}
        }   

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
           // HienThi();
        }

        private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
           // HienThi();
        }

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            //HienThi();
        }

        private void button_Thoat_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            DangNhap frm = new DangNhap();
            frm.Show();
        }

        private void TraCuuChuyenBay_HK_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the '_F__THUY_CNPM_DO_AN_KIMTHUY_CONNECT_SERVER_QLBVCB_MDFDataSet.CHUYENBAY' table. You can move, or remove it, as needed.
           this.cHUYENBAYTableAdapter.Fill(this._F__THUY_CNPM_DO_AN_KIMTHUY_CONNECT_SERVER_QLBVCB_MDFDataSet.CHUYENBAY);
            // TODO: This line of code loads data into the '_F__THUY_CNPM_DO_AN_KIMTHUY_CONNECT_SERVER_QLBVCB_MDFDataSet.SANBAY' table. You can move, or remove it, as needed.
            this.sANBAYTableAdapter.Fill(this._F__THUY_CNPM_DO_AN_KIMTHUY_CONNECT_SERVER_QLBVCB_MDFDataSet.SANBAY);

        }

    }
}
